﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Data;
public partial class Ajax_dlt_sw_hq : System.Web.UI.Page
{
    public List<Model.LotteryAnnouncement> GetPageListSQl(int PageIndex, int PageSize, string sql, out int totalCount)
    {

        string primaryKey = "openTime";
        totalCount = new DataAccess().GetCount<Model.LotteryAnnouncement>(primaryKey, sql);
        return new DataAccess().GetPage_List<Model.LotteryAnnouncement>(PageIndex, PageSize, primaryKey, primaryKey + " desc", sql);

    }
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpContext c = HttpContext.Current;
        string shouqiujiou = "";
        string shouqiudx = "";
        string shouqiusanlu = "";
        string weiqiujiou = "";
        string weiqiudx = "";
        string weiqiusanlu = "";
        string shouweihezhijiou = "";
        string shouweihezhidx = "";
        string shouweihezhisanlu = "";
        int lotteryType = ReadRequest.RequestInt("type");
        int count = ReadRequest.RequestInt("counts");
        int qsType = ReadRequest.RequestInt("qsType");
        int totalCount = 0;

        string sqlwhere = "";
        if (qsType == 1)
        {
            sqlwhere = " LotteryType =" + lotteryType + " and LotteryQS% 2= 1";//单期
        }
        else if (qsType == 2)
        {
            sqlwhere = " LotteryType =" + lotteryType + " and LotteryQS% 2= 0";//双期
        }
        else if (qsType == 3)
        {
            sqlwhere = " LotteryType =" + lotteryType + " and datepart(weekday,openTime)=2";//周一
        }
        else if (qsType == 4)
        {
            sqlwhere = " LotteryType =" + lotteryType + " and datepart(weekday,openTime)=4";//周三
        }
        else if (qsType == 5)
        {
            sqlwhere = " LotteryType =" + lotteryType + " and datepart(weekday,openTime)=7";//周六
        }
        else if (qsType == 0)
        {
            sqlwhere = "LotteryType =" + lotteryType;
        }

        List<Model.LotteryAnnouncement> modellist = GetPageListSQl(0, count, sqlwhere, out totalCount);

        if (count > 200)
        {
            modellist = modellist.FindAll(d => d.openTime.Year == count);

        }
        if (modellist != null)
        {
            #region
            for (int i = modellist.Count - 1; i >= 0; i--)
            {
                string[] redBall = modellist[i].LotteryNo.Split('+')[0].Split(',');
                string[] blueBall = modellist[i].LotteryNo.Split('+')[1].Split(',');
                int ball1 = int.Parse(blueBall[0]);//I球
                int ball2 = int.Parse(blueBall[1]);//II球

                //I球
                if (ball1 % 2 == 0)
                {
                    shouqiujiou += "1" + ","; //双
                }
                else
                {
                    shouqiujiou += "0" + ","; //单
                }
                if (ball1 > 0 && ball1 <= 6)
                {
                    shouqiudx += "1" + ","; //小
                }
                else if (ball1 >= 7 && ball1 <= 12)
                {
                    shouqiudx += "0" + ",";  //大 
                }
                if (ball1 % 3 == 0)
                {
                    shouqiusanlu += "0" + ","; //三路0
                }
                else if (ball1 % 3 == 1)
                {
                    shouqiusanlu += "1" + ","; //三路1
                }
                else if (ball1 % 3 == 2)
                {
                    shouqiusanlu += "2" + ","; //三路2
                }
                //II球
                if (ball2 % 2 == 0)
                {
                    weiqiujiou += "1" + ","; //双
                }
                else
                {
                    weiqiujiou += "0" + ","; //单
                }
                if (ball2 > 0 && ball2 <= 6)
                {
                    weiqiudx += "1" + ","; //小
                }
                else if (ball2 >= 7 && ball2 <= 12)
                {
                    weiqiudx += "0" + ",";  //大 
                }
                if (ball2 % 3 == 0)
                {
                    weiqiusanlu += "0" + ","; //三路0
                }
                else if (ball2 % 3 == 1)
                {
                    weiqiusanlu += "1" + ","; //三路1
                }
                else if (ball2 % 3 == 2)
                {
                    weiqiusanlu += "2" + ","; //三路2
                }

                //和值

                int shouweihezhi = ball1 + ball2;
                if (shouweihezhi % 2 == 0)
                {
                    shouweihezhijiou += "1" + ","; //双
                }
                else
                {
                    shouweihezhijiou += "0" + ","; //单
                }
                if (shouweihezhi <= 12)
                {
                    shouweihezhidx += "1" + ","; //小
                }
                else if (shouweihezhi >= 13)
                {
                    shouweihezhidx += "0" + ",";  //大 
                }
                if (shouweihezhi % 3 == 0)
                {
                    shouweihezhisanlu += "0" + ","; //三路0
                }
                else if (shouweihezhi % 3 == 1)
                {
                    shouweihezhisanlu += "1" + ","; //三路1
                }
                else if (shouweihezhi % 3 == 2)
                {
                    shouweihezhisanlu += "2" + ","; //三路2
                }
            }
            #endregion
            shouqiujiou = shouqiujiou.TrimEnd(',');
            shouqiudx = shouqiudx.TrimEnd(',');
            shouqiusanlu = shouqiusanlu.TrimEnd(',');
            weiqiujiou = weiqiujiou.TrimEnd(',');
            weiqiudx = weiqiudx.TrimEnd(',');
            weiqiusanlu = weiqiusanlu.TrimEnd(',');
            shouweihezhijiou = shouweihezhijiou.TrimEnd(',');
            shouweihezhidx = shouweihezhidx.TrimEnd(',');
            shouweihezhisanlu = shouweihezhisanlu.TrimEnd(',');

        }
        Response.Write(shouqiujiou + "*" + shouqiudx + "*" + shouqiusanlu + "*" + weiqiujiou + "*" + weiqiudx + "*" + weiqiusanlu + "*" + shouweihezhijiou + "*" + shouweihezhidx + "*" + shouweihezhisanlu);
        Response.End();




    }
}